package com.tanhua.app.controller;


import com.tanhua.app.exception.BusinessException;
import com.tanhua.app.exception.ErrorResult;

import com.tanhua.app.service.PeachBlossomService;

import com.tanhua.app.service.TanhuaService;
import com.tanhua.config.template.OssTemplate;

import com.tanhua.model.vo.SoundsVo;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/peachblossom")
public class PeachBlossomController {


    @Autowired
    private PeachBlossomService peachBlossomService;


    @Autowired
    private TanhuaService tanhuaService;


    /**
     * 发送语音
     * @param soundFile
     * @return
     * @throws IOException
     */
    @PostMapping
    public ResponseEntity saveUserSounds(@RequestParam("soundFile") MultipartFile soundFile) throws IOException {

        /*生成用户发送voice表数据*/
        peachBlossomService.saveUserSounds(soundFile);

        return ResponseEntity.ok(null);
    }


    /*接受语音*/
    @GetMapping
    public ResponseEntity getUserSounds(){

        SoundsVo soundsVo = peachBlossomService.getOneSounds();
        return ResponseEntity.ok(soundsVo);
    }



    /**
     * 喜欢
     */
    @GetMapping("{id}/love")
    public ResponseEntity<Void> likeUser(@PathVariable("id") Long likeUserId) {
        this.tanhuaService.likeUser(likeUserId);
        return ResponseEntity.ok(null);
    }


/*
    @GetMapping("{id}/unlove")
    public ResponseEntity<Void> noLikeUser(@PathVariable("id") Long likeUserId){
        this.tanhuaService.notLikeUser(likeUserId);

        return ResponseEntity.ok(null);
    }*/

}
